Introduction to EF Core Power Tools
I have been so busy with work lately that I haven't had time to write notes. Every day was either overtime, or wanting to work overtime but feeling too frustrated to do so, which left me with even less motivation to write. I recently resigned and spent some time being unproductive; while my emotions haven't fully settled, I feel like I should write something, so I'm recording this briefly.
Preface
In the past, Entity Framework provided a Database First development approach. However, in Entity Framework Core, only Code First remains.
Although you can simulate the Database First effect by reverse engineering EF code from a database, you encounter two main problems:
- Complex Commands: Different reverse engineering commands produce slightly different code, increasing the risk of code discrepancies due to operational errors.
- Customization Limitations: There is very limited customization available for the generated code.
EF Core Power Tools
Tool Introduction
EF Core Power Tools is one of the EF Visual Studio extensions recommended by the official website.
Reference link: EF Core tools and extensions
Key Features
- UI Interface Operation: Provides a graphical interface for reverse engineering, reducing the error rate of commands.
- Code Customization: Through the "Customize code using templates" setting, you can choose to use T4 templates or Handlebars for a higher degree of customization.
- Configuration Management: All settings are saved in the
efpt.config.jsonfile, ensuring that everyone maintaining the project uses the same configuration.
DateOnly and TimeOnly Support
In Entity Framework 8, support for DateOnly and TimeOnly mapping was added. With EF Core Power Tools, you can check the "Map DateOnly and TimeOnly" feature in the advanced settings. This prevents the previous behavior of mapping SQL Server date and time types to C# DateTime, avoiding potential misuse.
Scope of Support
In addition to existing SQL Server databases, you can also perform reverse engineering on Visual Studio database projects.
For specific operational steps, you can refer to the author's quick tutorial on GitHub: Reverse Engineering Quick Start. I won't go into detail here.
Limitations
EF Core Power Tools is not without its drawbacks:
Version Dependency Issues: The extension version is strictly dependent on the Entity Framework Core version, which in turn is dependent on the .NET version.
Different projects may require different versions of EF Core Power Tools:
EF Core Power Tools 2.5.1429: The last version to support Entity Framework Core 3.1; it does not support Entity Framework Core 8.
EF Core Power Tools 2.6.698: The last version to support Entity Framework Core 7.
Therefore, if you are maintaining multiple projects spanning from .NET Core 3.1 to .NET 8, you might need to install multiple versions of Visual Studio (e.g., Visual Studio Release and Visual Studio Preview) to accommodate different versions of the extension.
Limited Database Support: Originally, it only supported SQL Server. Although I see "MySQL" and "Snowflake" options when adding custom database connections, I haven't actually used the latter two.
EF Core Power Pack
Solution
To address the limitation that EF Core Power Tools can only perform reverse engineering for SQL Server, the author developed the EF Core Power Pack extension to support PostgreSQL and SQLite.
Installation and Configuration
After installing EF Core Power Pack, the system will additionally install the following extensions:
- VisualStudio.Data.Sqlite
- Npgsql PostgreSQL Integration
Usage
After installation, when "Adding a Database Connection":
- Click the "Change(C)" button next to Data connection.
- Select the newly added "PostgreSQL" or "SQLite" database type from the list.
Change Log
- 2025-07-07 Initial document creation.